//! error  definition
use error_chain::error_chain;
error_chain! {
    foreign_links {
        HdWallert(hdwallet::error::Error);
        FromHexError(rustc_serialize::hex::FromHexError);
        Base64Error(base64::DecodeError);
        Secp256k1Error(hdwallet::secp256k1::Error);
        SerdeJsonError(serde_json::Error);
        FromTtf8Error(std::string::FromUtf8Error);
    }
    errors {
        ArgumentWrong(msg: String) {
            description("function argument got an error!")
            display("Argument error: {}", msg)
        }
        Bip39Mnemonic(msg: String) {
            description("Bip39Mnemonic got an error!")
            display("Bip39Mnemonic error: {}", msg)
        }
    }
}

pub fn error_msg(msg: &str) -> Error {
    Error::from_kind(ErrorKind::Msg(msg.to_string()))
}
